package com.moon.interface_api.job;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
public class RollNewsJob {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    
    //每天00：01 
    //@Scheduled(cron="0 01 00 * * ?")
    //@Scheduled(fixedRate=5000)
    public void rollNewsCreate() {
        logger.info("滚动新闻定时器开始");
        //生成24小时
        /*for (int i = 0 ; i < 24; i++) {
            ArrayList<NewsDO> newsList = new ArrayList<>();
            //生成第i小时的数据
            int num = StringUtil.getNum(50, 70);
            for (int j = 0; j < num; j++) {
                NewsDO newsDO = new NewsDO();
                newsDO.setNickName(StringUtil.getTelByNick());
                //时间
                String start = null;
                String end = null;
                String s = DateUtil.formatDate(DateUtil.DATE_YYYYMMDD, new Date());
                if(i == 0){
                    start = s+" 00:00:00";
                    end = s+ " 01:00:00";
                }else if(i == 1){
                    start = s+" 01:00:00";
                    end = s+ " 02:00:00";
                }else if(i == 2){
                    start = s+" 02:00:00";
                    end = s+ " 03:00:00";
                }else if(i == 3){
                    start = s+" 03:00:00";
                    end = s+ " 04:00:00";
                }else if(i == 4){
                    start = s+" 04:00:00";
                    end = s+ " 05:00:00";
                }else if(i == 5){
                    start = s+" 05:00:00";
                    end = s+ " 06:00:00";
                }else if(i == 6){
                    start = s+" 06:00:00";
                    end = s+ " 07:00:00";
                }else if(i == 7){
                    start = s+" 07:00:00";
                    end = s+ " 08:00:00";
                }else if(i == 8){
                    start = s+" 08:00:00";
                    end = s+ " 09:00:00";
                }else if(i == 9){
                    start = s+" 09:00:00";
                    end = s+ " 10:00:00";
                }else if(i == 23){
                    start = s+" 23:00:00";
                    end = s+ " 23:59:59";
                }else{
                    start = s+" "+i+":00:00";
                    end = s+ " "+(i+1)+":00:00";
                }
                Date startDate = DateUtil.parseDate(DateUtil.DATE_TIME_PATTERN, start);
                Date endDate = DateUtil.parseDate(DateUtil.DATE_TIME_PATTERN, end);
                Date createTime = DateUtil.getRandomTime(startDate,endDate);
                newsDO.setCreateTime(createTime);
                //内容
                int infoNum = StringUtil.getNum(1,4);
                String info = null;
                if(infoNum == 1){
                    info = "申请成功";
                }else if(infoNum == 2){
                    int money = StringUtil.getNum(50000, 300000);
                    info = "成功贷到"+(money - money%1000)+"元";
                }else if(infoNum == 3){
                    int type = StringUtil.getNum(1, 6);
                    if(type == 1){
                        info = "成功申请宅E经营贷";
                    }else if(type == 2){
                        info = "成功申请优房贷";
                    }else if(type == 3){
                        info = "成功申请保单贷";
                    }else if(type == 4){
                        info = "成功申请薪金贷";
                    }else if(type == 5){
                        info = "成功申请氧气贷";
                    }else{
                        info = "成功申请新一贷";
                    }
                    
                }else {
                    int money = StringUtil.getNum(50000, 300000);
                    info = "提取"+(money - money%1000)+"额度";
                }
                newsDO.setInfo(info);
                newsDO.setTime(DateUtil.formatDate(DateUtil.TIME_PATTERN,createTime));
                
                newsList.add(newsDO);
                
            }
            newsService.save(newsList);
        }*/



        logger.info("滚动新闻定时器结束");
    }
}
